const Koa = require("koa");
const router=require("koa-router")();
const app=new Koa();
//中间件  任何请求都要走这里
app.use((ctx,next)=>{
  console.log(ctx)
  next()
})
router.get('/students', (ctx, next) => {
  const students=[
    {
      id:0,
      name:"xixi",
      age:18
    },
    {
      id:1,
      name:"haha",
      age:20
    }
  ]
  ctx.body=students
})
app.use(router.routes());
app.use(router.allowedMethods());
app.listen(5000,()=>{
  console.log('http://localhost:5000')
})